<!doctype html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<pre>
    重塑数组：filter(), concat(), slice()

    这些不会改变原始数组，但总是返回一个新数组。当使用非变异方法时，可以用新数组替换旧数组，从而更新视图

</pre>
<div id="app">
    <ul>
        <li v-for="n of list">{{n}}</li>
    </ul>
    <button @click="map">map</button>
    <button @click="filter">filter</button>
    <button @click="concat">concat</button>
    <button @click="slice">slice</button>
</div>
</body>
<script src="../../vender/vue@2.4.2.js"></script>
<script>

    var app=new Vue({
        el:'#app',
        data:{
            list:[0,1,2,3,4,5,6,7,8,9]
        },
        methods:{
            map: function () {
                this.list=this.list.map(n=>n*n);
            },
            filter: function () {
                this.list=this.list.filter(n=>n);
            },
            concat: function () {
                this.list=this.list.concat('a','b','c');
            },
            slice: function () {
                this.list=this.list.slice(2,-2);
            }
        }
    });

</script>
</html>